package cn.angis.db.config;

import com.beetl.sql.pref.PerformanceConfig;
import com.zaxxer.hikari.HikariDataSource;
import org.beetl.sql.core.ConnectionSource;
import org.beetl.sql.core.ConnectionSourceHelper;
import org.beetl.sql.core.SQLManager;
import org.beetl.sql.core.SQLManagerBuilder;
import org.noear.solon.annotation.Bean;
import org.noear.solon.annotation.Configuration;
import org.noear.solon.annotation.Inject;
import org.noear.solon.vault.annotation.VaultInject;

import javax.sql.DataSource;


@Configuration
public class Config {

    @Bean
    public DataSource ds(@VaultInject("${database.db1}") HikariDataSource dataSource) {
        return dataSource;
    }
    @Bean
    public void init(@Inject DataSource ds) {
        ConnectionSource source = ConnectionSourceHelper.getSingle(ds);
        SQLManagerBuilder builder = new SQLManagerBuilder(source);
        SQLManager sqlManager = builder.build();
        PerformanceConfig performanceConfig = new PerformanceConfig();
        performanceConfig.config(sqlManager);
        SQLManager.javabeanStrict(false);
    }

}




